from selenium import webdriver

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from time import sleep
 

driver = webdriver.Chrome()
def isElementExist(selector):
    try:
        ele = driver.find_element_by_css_selector(selector)
        return True
    except:
        return False

def getElement(selector):
    while True:
        print('getElement:' + selector)
        if isElementExist(selector):
            break
        sleep(0.1)
    return driver.find_element_by_css_selector(selector)
    
def test():
    driver.maximize_window()
    driver.get("https://wwww.baidu.com")
   

    # a = driver.find_element_by_id('aaa')
    if isElementExist('#su'):
        print(1111)
        a = getElement('#su')
        print(a)
        print(type(a))
    else:
        print(222)

if __name__ == "__main__":
    test()
   